/**
 * Author  zxy
 * Date  2023/8/16 23:12
 */

import java.util.*;

public class Question11 {
    public static void main(String[] args) {

        int[] arrs = {3,1,6,-2,7,9,12,8,4};
        func(arrs, 10);

    }

    /*
    * 找出数组中两个数之和等于 target 的组合
    * */
    public static void func(int[] arrs, int tar) {
        Arrays.sort(arrs);

        int start = 0;
        int end = arrs.length - 1;

        while (start < end) {
            int sum = arrs[start] + arrs[end];
            if (sum == tar) {
                System.out.println(arrs[start] +   + arrs[end]);
                start++;
                end--;
            }
            else if (sum > tar) {
                end--;
            }
			else {
                start++;
            }
        }
    }
}

